package com.nys.conci.base.validador;

import com.nys.conci.base.validador.anotacion.Telefono;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 *
 * @author Adam M. Gamboa González
 */
public class TelefonoValidator implements ConstraintValidator<Telefono, String> {
    
    private final String regex = "\\d{8}";
    @Override
    public void initialize(Telefono constraintAnnotation) {
    }
    
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(value == null || value.trim().equals("")){
            return false;
        }
        return value.matches(regex);
    }
}
